﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace RegistrationController
{
    public class hpm_ezUtilsAdapter
    {
        public static void executeNonQuery(string strSP, params SqlParameter[] parameters) {
            /* TODO : Make it generic */
            SqlConnection PubsConn = new SqlConnection 
                ("Data Source=localhost;Database=eHMS;uid=hms_usr;password=@!hm$u$r!@;Pooling=false");
            SqlCommand testCMD = new SqlCommand 
                (strSP, PubsConn);

            testCMD.CommandType = CommandType.StoredProcedure;

            foreach (SqlParameter objParam in parameters) {
                if (objParam.Value == null)
                {
                    objParam.Value = DBNull.Value;
                }
                testCMD.Parameters.Add(objParam);
            }
   
            PubsConn.Open();

            testCMD.ExecuteNonQuery().ToString();

            PubsConn.Close();
        }
    }
}
